package cn.zane.designPattern.createPatterns.factoryMethodPatterns.design.store.impl;

import cn.zane.designPattern.createPatterns.factoryMethodPatterns.design.store.ICommodity;
import cn.zane.designPattern.createPatterns.factoryMethodPatterns.oldCode.card.IQiYiCardService;
import com.alibaba.fastjson2.JSON;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * @Author: zane
 * @Date: 2024/12/25
 * @Description: 商品：卡片服务
 */
@Slf4j
public class CardCommodityService implements ICommodity {

    // 模拟注入
    private IQiYiCardService iqiYiCardService = new IQiYiCardService();

    @Override
    public void sendCommodity(String uId, String commodityId, String bizId, Map<String, String> extMap) throws Exception {
        String mobile = queryUserMobile(uId);
        iqiYiCardService.grantToken(mobile, bizId);
        log.info("请求参数[爱奇艺兑换卡]->uId:{} commodityId:{} bizId:{} extMap:{}", uId, commodityId, bizId, JSON.toJSONString(extMap));
        log.info("测试结果[爱奇艺兑换卡]:success");
    }

    private String queryUserMobile(String uId) {
        return "01234567891";
    }
}
